home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc A) / Acorn User China CD-ROM (UK) (Disc A).bin / DEMON / RISCOS2 / BMSRC.ARC / BM / c / BMUTIL next >
Encoding:
Text File  |  1992-03-22  |  22.5 KB  |  700 lines

  1. /* bmutil.c */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7. #include <errno.h>
  8. #include "bm.h"
  9. #include "header.h"
  10.  
  11. static unsigned long    mboxsize;
  12. static int      anyread;
  13.  
  14. int initnotes(void)
  15. {
  16.         FILE    *ifile;
  17.         register struct let *cmsg;
  18.         int     i, ret;
  19.         struct stat mstat;
  20.  
  21.         if (!stat(mfilename,&mstat))
  22.                 mboxsize = mstat.st_size;
  23.         if ((ifile = fopen(mfilename,"rt")) == NULLFILE) {
  24.                 panic(nomail);
  25.                 mfile = NULLFILE;
  26.                 return 0;
  27.         } 
  28.         if ((mfile = tmpfile()) == NULLFILE) {
  29.                 panic("Unable to create tmp file");
  30.                 fclose(ifile);
  31.                 return -1;
  32.         }
  33.         nmsgs = 0;
  34.         current = 0;
  35.         change = 0;
  36.         newmsgs = 0;
  37.         anyread = 0;
  38.         ret = readnotes(ifile);
  39.         fclose(ifile);
  40.         if (ret != 0)
  41.                 return -1;
  42.         for (cmsg = &mbox[1],i = 1; i <= nmsgs; i++, cmsg++)  
  43.                 if ((cmsg->status & READ) == 0) {
  44.                         newmsgs++;
  45.                         if (current == 0)
  46.                                 current = i;
  47.                 }
  48.         /* start at one if no new messages */
  49.         if (current == 0)
  50.                 current++;
  51.  
  52.         return 0;
  53.  
  54. }
  55.  
  56. /* readnotes assumes that ifile is pointing to the first
  57.  * message that needs to be read.  For initial reads of a
  58.  * notesfile, this will be the beginning of the file.  For
  59.  * rereads when new mail arrives, it will be the first new
  60.  * message.
  61.  */
  62. int readnotes(FILE *ifile)
  63. {
  64.         char    tstring[LINELEN];
  65.         long    cpos;
  66.         register struct let *cmsg;
  67.         register char *line;
  68.  
  69.         cmsg = (struct let *)NULL;
  70.         line = tstring;
  71.         while(!feof(ifile)) {
  72.                 fgets(line,LINELEN,ifile);
  73.                 /* scan for begining of a message */
  74.                 if(strncmp(line,"From ",5) == 0) {
  75.                         cpos = ftell(mfile);
  76.                         fputs(line,mfile);
  77.                         if (nmsgs == maxlet) {
  78.                                 panic("Mail box full: > %d messages\n",maxlet);
  79.                                 fclose(mfile);
  80.                                 return -1;
  81.                         }
  82.                         nmsgs++;
  83.                         cmsg = &mbox[nmsgs];
  84.                         cmsg->start = cpos;
  85.                         cmsg->status = 0;
  86.                         cmsg->size = strlen(line);
  87.                         while (!feof(ifile)) {
  88.                                 if (fgets(line,LINELEN,ifile) == NULLCHAR)
  89.                                         break;
  90.                                 if (*line == '\n') { /* done header part */
  91.                                         cmsg->size++;
  92.                                         putc(*line, mfile);
  93.                                         break;
  94.                                 }
  95.                                 if (htype(line) == STATUS) {
  96.                                         if (line[8] == 'R') 
  97.                                                 cmsg->status |= READ;
  98.                                         continue;
  99.                                 }
  100.                                 cmsg->size += strlen(line);
  101.                                 if (fputs(line,mfile) == EOF) {
  102.                                         panic("%s: %s", "tmp file", strerror(errno));
  103.                                         fclose(mfile);
  104.                                         return -1;
  105.                                 }
  106.  
  107.                         }
  108.                 } else if (cmsg) {
  109.                         cmsg->size += strlen(line);
  110.                         fputs(line,mfile);
  111.                 }
  112.         }
  113.         return 0;
  114. }
  115.  
  116. /* list headers of a notesfile a message */
  117. void listnotes(void)
  118. {
  119.         register struct let *cmsg;
  120.         register char   *p, *s;
  121.         char    smtp_date[SLINELEN];
  122.         char    smtp_from[SLINELEN];
  123.         char    smtp_subject[SLINELEN]; 
  124.         char    tstring[LINELEN];
  125.         int     i;
  126.         long    size;
  127.  
  128. /*
  129.         if (mfile == NULLFILE)
  130.                 return;
  131. */
  132.  
  133.         if (!wopen(LISTNOTES)) {
  134.                 panic("Cannot open List Notes window.");
  135.                 return;
  136.         }
  137.  
  138.         wclear(LISTNOTES);
  139.  
  140.         wprintf(LISTNOTES, "Mailbox %s - %d messages %d new\n\n",mfilename,nmsgs,newmsgs);
  141.  
  142.         for (cmsg = &mbox[1],i = 1; i <= nmsgs; i++, cmsg++) {
  143.                 *smtp_date = '\0';
  144.                 *smtp_from = '\0';
  145.                 *smtp_subject = '\0';
  146.                 fseek(mfile,cmsg->start,0);
  147.                 size = cmsg->size;
  148.                 while (!feof(mfile) && size > 0) {
  149.                         fgets(tstring,sizeof(tstring),mfile);
  150.                         if (*tstring == '\n')   /* end of header */
  151.                                 break;
  152.                         size -= strlen(tstring);
  153.                         rip(tstring);
  154.                         /* handle continuation later */
  155.                         if (*tstring == ' '|| *tstring == '\t')
  156.                                 continue;
  157.                         switch(htype(tstring)) {
  158.                         case FROM:
  159.                                 if((p = getname(tstring)) == NULLCHAR) {
  160.                                         p = &tstring[6];
  161.                                         while(*p && *p != ' ' && *p != '(')
  162.                                                 p++;
  163.                                         *p = '\0';
  164.                                         p = &tstring[6];
  165.                                 }
  166.                                 sprintf(smtp_from,"%.30s",p);
  167.                                 break;
  168.                         case SUBJECT:
  169.                                 sprintf(smtp_subject,"%.34s",&tstring[9]);
  170.                                 break;
  171.                         case DATE:
  172.                                 if ((p = strchr(tstring,',')) == NULLCHAR)
  173.                                         p = &tstring[6];
  174.                                 else
  175.                                         p++;
  176.                                 /* skip spaces */
  177.                                 while (*p == ' ') p++;
  178.                                 if(strlen(p) < 17)
  179.                                         break;  /* not a valid length */
  180.                                 s = smtp_date;
  181.                                 /* copy day */
  182.                                 if (atoi(p) < 10 && *p != '0') {
  183.                                         *s++ = ' ';
  184.                                 } else
  185.                                         *s++ = *p++;
  186.                                 *s++ = *p++;
  187.  
  188.                                 *s++ = ' ';
  189.                                 while (*p == ' ')
  190.                                         p++;
  191.                                 /* copy month */
  192.                                 *s++ = *p++;
  193.                                 *s++ = *p++;
  194.                                 *s++ = *p++;
  195.                                 while (*p == ' ')
  196.                                         p++;
  197.                                 /* skip year */
  198.                                 while (isdigit(*p))
  199.                                         p++;
  200.                                 /* copy time */
  201.                                 *s++ = *p++;    /* space */
  202.                                 *s++ = *p++;    /* hour */
  203.                                 *s++ = *p++;
  204.                                 *s++ = *p++;    /* : */
  205.                                 *s++ = *p++;    /* min */
  206.                                 *s++ = *p++;
  207.                                 *s = '\0';
  208.                                 break;
  209.                         case NOHEADER:
  210.                                 break;
  211.                         }
  212.                 }
  213.                 wprintf(LISTNOTES, "%c%c%c%3d %-27.27s %-12.12s %5ld %.25s\n",
  214.                     (i == current ? '>' : ' '),
  215.                     (cmsg->status & DELETE ? 'D' : ' '),
  216.                     (cmsg->status & READ ? 'Y' : 'N'),
  217.                     i, smtp_from, smtp_date,
  218.                     cmsg->size, smtp_subject);
  219.         }
  220.  
  221.         whome(LISTNOTES);
  222. }
  223.  
  224. /*  save msg on stream - if noheader set don't output the header */
  225. int msgtofile(int msg, FILE *tfile, int noheader)
  226. {
  227.         char    tstring[LINELEN];
  228.         long    size;
  229.  
  230.         if (mfile == NULLFILE) {
  231.                 panic(nomail);
  232.                 return -1;
  233.         }
  234.         fseek(mfile,mbox[msg].start,0);
  235.         size = mbox[msg].size;
  236.         if ((mbox[msg].status & READ) == 0) {
  237.                 mbox[msg].status |= READ;
  238.                 change = 1;
  239.         }
  240.  
  241.         if (noheader) {
  242.                 /* skip header */
  243.                 while (!feof(mfile) && size > 0) {
  244.                         fgets(tstring,sizeof(tstring),mfile);
  245.                         size -= strlen(tstring);
  246.                         if (*tstring == '\n')
  247.                                 break;
  248.                 }
  249.         }
  250.         while (!feof(mfile) && size > 0) {
  251.                 fgets(tstring,sizeof(tstring),mfile);
  252.                 size -= strlen(tstring);
  253.                 fputs(tstring,tfile);
  254.                 if (ferror(tfile)) {
  255.                         panic("Error writing mail file");
  256.                         fclose(tfile);
  257.                         return -1;
  258.                 }
  259.         }
  260.         return 0;
  261. }
  262.  
  263. /*  delmsg - delete message in current notesfile */
  264. void delmsg(int msg)
  265. {
  266.         if (mfile == NULLFILE) {
  267.                 panic(nomail);
  268.                 return;
  269.         }
  270.         mbox[msg].status |= DELETE;
  271.         change = 1;
  272. }
  273.  
  274. /*  reply - to a message  */
  275. void reply(int msg)
  276. {
  277.         char    to[SLINELEN];
  278.         char    subject[LINELEN];
  279.         char    tstring[LINELEN];
  280.         char    *p,*s;
  281.         long    size;
  282.  
  283.         if (mfile == NULLFILE) {
  284.                 panic(nomail);
  285.                 return;
  286.         }
  287.         *to = '\0';
  288.         *subject = '\0';
  289.         fseek(mfile,mbox[msg].start,0);
  290.         size = mbox[msg].size;
  291.         while (!feof(mfile) && size > 0) {
  292.                 fgets(tstring,sizeof(tstring),mfile);
  293.                 size -= strlen(tstring);
  294.                 if (*tstring == '\n')   /* end of header */
  295.                         break;
  296.                 rip(tstring);
  297.                 if ((*to == '\0' && htype(tstring) == FROM)
  298.                     || htype(tstring) == REPLYTO) {
  299.                         s = getname(tstring);
  300.                         if (s == NULLCHAR) {
  301.                                 p = strchr(tstring,':');
  302.                                 p += 2;
  303.                                 s = p;
  304.                                 while(*p && *p != ' ' && *p != '(')
  305.                                         p++;
  306.                                 *p = '\0';
  307.                         }
  308.                         *to = '\0';
  309.                         strncat(to,s,sizeof(to));
  310.                 } else if (htype(tstring) == SUBJECT) {
  311.                         if (strncmp(&tstring[9], "Re:", 3))  /* No Re: yet? */
  312.                                 sprintf(subject,"Re: %s\n",&tstring[9]);
  313.                         else    /* there's an Re:, let's not add another */
  314.                                 sprintf(subject,"%s\n",&tstring[9]) ;
  315.                 }
  316.         }
  317.         if (*to == '\0')
  318.                 panic("No reply address in message\n");
  319.         else
  320.                 dosmtpsend(NULLFILE,to,subject);
  321. }
  322.  
  323.  
  324. /* close the temp file while coping mail back to the mailbox */
  325. int closenotes(void)
  326. {
  327.         register struct let *cmsg;
  328.         register char *line;
  329.         char tstring[LINELEN];
  330.         long size;
  331.         int i;
  332.         int ret;
  333.         int written = 0;
  334.         FILE    *nfile;
  335.  
  336.         if (mfile == NULLFILE)
  337.                 return 0;
  338.         if (!change) {
  339.                 fclose(mfile);
  340.                 return 0;
  341.         }
  342.         line = tstring;
  343.         fseek(mfile,0L,2);
  344.         if (isnewmail()) {
  345.  
  346.                 panic("isnewmail = TRUE\n");
  347.  
  348.                 if ((nfile = fopen(mfilename,"rt")) == NULLFILE)
  349.                         panic("%s: %s", mfilename, strerror(errno));
  350.                 else {
  351.                         /* seek to end of old msgs */
  352.                         fseek(nfile,mboxsize,0);
  353.                         /* seek to end of tempfile */
  354.                         fseek(mfile,0L,2);
  355.                         ret = readnotes(nfile);   /* get the new mail */
  356.                         fclose(nfile);
  357.                         if (ret != 0) {
  358.                                 panic("Error updating mail file\n");
  359.                                 return -1;
  360.                         }
  361.                 }
  362.         }
  363.  
  364.         if ((nfile = fopen(mfilename,"wt")) == NULLFILE) {
  365.                 panic("Unable to open %s\n",mfilename);
  366.                 return -1;
  367.         }
  368.         /* copy tmp file back to notes file */
  369.         for (cmsg = &mbox[1],i = 1; i <= nmsgs; i++, cmsg++) {
  370.                 fseek(mfile,cmsg->start,0);
  371.                 size = cmsg->size;
  372.                 if ((cmsg->status & DELETE))
  373.                         continue;
  374.  
  375.                 written++;
  376.                 /* copy the header */
  377.                 while (!feof(mfile) && size > 0) {
  378.                         fgets(line,LINELEN,mfile);
  379.                         size -= strlen(line);
  380.                         if (*line == '\n') {
  381.                                 if ((cmsg->status & READ) != 0)
  382.                                         fprintf(nfile,"Status: R\n");
  383.                                 fprintf(nfile,"\n");
  384.                                 break;
  385.                         }
  386.                         fputs(line,nfile);
  387.                 }
  388.                 while (!feof(mfile) && size > 0) {
  389.                         fgets(line,LINELEN,mfile);
  390.                         fputs(line,nfile);
  391.                         size -= strlen(line);
  392.                         if (ferror(nfile)) {
  393.                                 panic("Error writing mail file\n");
  394.                                 fclose(nfile);
  395.                                 fclose(mfile);
  396.                                 return -1;
  397.                         }
  398.                 }
  399.         }
  400.         nmsgs = 0;
  401.         fclose(nfile);
  402.         fclose(mfile);
  403.         mfile = NULLFILE;
  404.  
  405.         if (written == 0)
  406.                 remove(mfilename);                 
  407.  
  408.         return 0;
  409. }
  410.  
  411. /* get a message id from the sequence file */
  412. long get_msgid(void)
  413. {
  414.         char sfilename[SLINELEN];
  415.         char s[20];
  416.         long sequence = 0L;
  417.         FILE *sfile;
  418.  
  419.         sprintf(sfilename,"%s.sequence", mqueue);
  420.         sfile = fopen(sfilename,"rt");
  421.  
  422.         /* if sequence file exists, get the value, otherwise set it */
  423.         if (sfile != NULLFILE) {
  424.                 fgets(s,sizeof(s),sfile);
  425.                 sequence = atol(s);
  426.         /* Keep it in range of and 8 digit number to use for dos name prefix. */
  427.                 if (sequence < 0L || sequence > 99999999L )
  428.                         sequence = 0L;
  429.                 fclose(sfile);
  430.         }
  431.  
  432.         /* increment sequence number, and write to sequence file */
  433.         sfile = fopen(sfilename,"wt");
  434.         fprintf(sfile,"%ld",++sequence);
  435.         fclose(sfile);
  436.         return sequence;
  437. }
  438.  
  439. /* Given a string of the form <user@host>, extract the part inside the
  440.  * brackets and return a pointer to it.
  441.  */
  442. char *getname(register char *cp)
  443. {
  444.         char *cp1;
  445.  
  446.         if((cp = strchr(cp,'<')) == NULLCHAR)
  447.                 return NULLCHAR;
  448.         cp++;   /* cp -> first char of name */
  449.         if((cp1 = strchr(cp,'>')) == NULLCHAR)
  450.                 return NULLCHAR;
  451.         *cp1 = '\0';
  452.         return cp;
  453. }
  454.  
  455. /* create mail lockfile */
  456. int mlock(char *dir, char *id)
  457. {
  458.         char lockname[SLINELEN];
  459.         FILE *fp;
  460.         /* Try to create the lock file in an atomic operation */
  461.         sprintf(lockname,"%s.lock.%s",dir,id);
  462.         if((fp = fopen(lockname, "wt")) == NULL)
  463.                 return -1;
  464.         fclose(fp);
  465.         return 0;
  466. }
  467.  
  468. /* remove mail lockfile */
  469. void rmlock(char *dir, char *id)
  470. {
  471.         char lockname[SLINELEN];
  472.         sprintf(lockname,"%s.lock.%s",dir,id);
  473.         remove(lockname);
  474. }
  475.  
  476. /* parse a line into argv array. Return argc */
  477. int parse(register char *line, char *argv[], int maxargs)
  478. {
  479.         int argc;
  480.         int qflag;
  481.         register char *cp;
  482.  
  483.         for(argc = 0; argc < maxargs; argc++)
  484.                 argv[argc] = NULLCHAR;
  485.  
  486.         for(argc = 0; argc < maxargs;){
  487.                 qflag = 0;
  488.                 /* Skip leading white space */
  489.                 while(*line == ' ' || *line == '\t')
  490.                         line++;
  491.                 if(*line == '\0')
  492.                         break;
  493.                 /* Check for quoted token */
  494.                 if(*line == '"'){
  495.                         line++; /* Suppress quote */
  496.                         qflag = 1;
  497.                 }
  498.                 argv[argc++] = line;    /* Beginning of token */
  499.                 /* Find terminating delimiter */
  500.                 if(qflag){
  501.                         /* Find quote, it must be present */
  502.                         if((line = strchr(line,'"')) == NULLCHAR){
  503.                                 return -1;
  504.                         }
  505.                         *line++ = '\0';
  506.                 } else {
  507.                         /* Find space or tab. If not present,
  508.                          * then we've already found the last
  509.                          * token.
  510.                          */
  511.                         if((cp = strchr(line,' ')) == NULLCHAR
  512.                             && (cp = strchr(line,'\t')) == NULLCHAR){
  513.                                 break;
  514.                         }
  515.                         *cp++ = '\0';
  516.                         line = cp;
  517.                 }
  518.         }
  519.         return argc;
  520. }
  521.  
  522. int lockit(void)
  523. {
  524.         if(mlock(maildir,notename)) {
  525.                 panic("Mail file is busy");
  526.                 if (mfile != NULLFILE)
  527.                         fclose(mfile);
  528.                 mfile = NULLFILE;
  529.                 return 1;
  530.         }
  531.         return 0;
  532. }
  533.  
  534. /* print the next message or the current on of new */
  535. void printnext(void)
  536. {
  537.         if (mfile == NULLFILE)
  538.                 return;
  539.         if ((mbox[current].status & READ) != 0) {
  540.                 if (current == 1 && anyread == 0)
  541.                         ;
  542.                 else if (current < nmsgs) {
  543.                         current++;
  544.                 } else {
  545.                         panic("Last message");
  546.                         return;
  547.                 }
  548.         }
  549.         displaymsg(current);
  550.         anyread = 1;
  551. }
  552.  
  553. /*  display message on the crt given msg number */
  554. void displaymsg(int msg)
  555. {
  556.         register int c;
  557.         register int col;
  558.         char    buf[200];          /* line buffer */
  559.         int     cnt;
  560.         long    tsize, size;
  561.  
  562.         if (mfile == NULLFILE) {
  563.                 panic(nomail);
  564.                 return;
  565.         }
  566.         if( msg < 0 || msg > nmsgs) {
  567.                 panic(badmsg,msg);
  568.                 return;
  569.         }
  570.  
  571.         if (!wopen(DISPLAYMSG)) {
  572.                 panic("Cannot open Message Display window");
  573.                 return;
  574.         }
  575.  
  576.         wclear(DISPLAYMSG);
  577.  
  578.         fseek(mfile,mbox[msg].start,0);
  579.         size = mbox[msg].size;
  580.         tsize = size;
  581.  
  582.         wprintf(DISPLAYMSG, "Message #%d %s\n",
  583.                 msg, mbox[msg].status & DELETE ? "[Deleted]" : "");
  584.         if ((mbox[msg].status & READ) == 0) {
  585.                 mbox[msg].status |= READ;
  586.                 change = 1;
  587.         }
  588.         col = 0;
  589.         while (!feof(mfile) && size > 0) {
  590.                 for (col = 0;  col < 200-1;) {
  591.                         c = fgetc(mfile);
  592.                         size--;
  593.                         if (feof(mfile) || size == 0)   /* end this line */
  594.                                 break;
  595.                         if (c == '\t') {
  596.                                 cnt = col + 8 - (col & 7);
  597.                                 if (cnt >= 200)      /* end this line */
  598.                                         break;
  599.                                 while (col < cnt)
  600.                                         buf[col++] = ' ';
  601.                         } else if (c == '\n')
  602.                                 break;
  603.                         else
  604.                                 buf[col++] = c;
  605.                 }
  606.                 buf[col] = '\0';
  607.                 wprintf(DISPLAYMSG, "%s\n",buf);
  608.                 col = 0;
  609.         }
  610.  
  611.         whome(DISPLAYMSG);
  612. }
  613.  
  614. /* list jobs wating to be sent in the mqueue */
  615. void listqueue(void)
  616. {
  617.         char tstring[80];
  618.         char workfile[80];
  619.         char line[20];
  620.         char host[SLINELEN];
  621.         char to[SLINELEN];
  622.         char from[SLINELEN];
  623.         char    status;
  624.         struct stat stbuf;
  625.         FILE *fp;
  626.  
  627.         if (!wopen(LISTQUEUE)) {
  628.                 panic("Cannot open List Queue Window");
  629.                 return;
  630.         }
  631.  
  632.         wclear(LISTQUEUE);  
  633.  
  634.         wprintf(LISTQUEUE, "S     Job    Size Date  Time  Host                 From\n");
  635.  
  636.         sprintf(workfile,"%s.work",mqueue);
  637.         filedir(workfile,0,line);
  638.         while(line[0] != '\0') {
  639.                 sprintf(tstring,"%s.work.%s",mqueue,line);
  640.                 if ((fp = fopen(tstring,"rt")) == NULLFILE) {
  641.                        panic("%s: %s", tstring, strerror(errno));
  642.                        continue;
  643.                 }
  644.                 sprintf(tstring,"%s.lock.%s",mqueue,line);
  645.                 if (access(tstring,0))
  646.                        status = ' ';
  647.                 else
  648.                        status = 'L';
  649.                 sprintf(tstring,"%s.text.%s",mqueue,line);
  650.                 stat(tstring,&stbuf);
  651.                 fgets(host,sizeof(host),fp);
  652.                 rip(host);
  653.                 fgets(from,sizeof(from),fp);
  654.                 rip(from);
  655.                 wprintf(LISTQUEUE, "%c %7s %7d %s %-20s %s\n      ",
  656.                        status, line, stbuf.st_size,
  657.                        stbuf.st_ctime, host,from);
  658.                 while (fgets(to,sizeof(to),fp) != NULLCHAR) {
  659.                        rip(to);
  660.                        wprintf(LISTQUEUE, "%s ",to);
  661.                 }
  662.                 wprintf(LISTQUEUE, "\n");
  663.                 fclose(fp);
  664.  
  665.                 filedir(workfile,1,line);
  666.         }
  667.  
  668.         whome(LISTQUEUE);
  669. }
  670.  
  671. /* kill a job in the mqueue */
  672. void killjob(char *j)
  673. {
  674.         char s[SLINELEN];
  675.  
  676.         sprintf(s,"%s.lock.%s",mqueue,j);
  677.         remove(s);
  678.         sprintf(s,"%s.work.%s",mqueue,j);
  679.         if (remove(s))
  680.                 panic("Job id %s not found\n",j);
  681.         sprintf(s,"%s.text.%s",mqueue,j);
  682.         remove(s);
  683. }
  684.  
  685. /* check the current mailbox to see if new mail has arrived.
  686. * checks to see if the file has increased in size.
  687. * returns true if new mail has arrived.
  688. */
  689. int isnewmail(void)
  690. {
  691.         struct stat mstat;
  692.         if (mfile == NULLFILE)
  693.                 return 0;
  694.         if (stat(mfilename,&mstat))
  695.                 panic("unable to stat %s",mfilename);
  696.         else if (mstat.st_size > mboxsize)
  697.                         return 1;
  698.         return 0;
  699. }
  700.